#define IP2C_DB_IDENT "IP2C"
#define IP2C_DB_VERS_HI 1
#define IP2C_DB_VERS_LO 1

typedef char ip2c_country_code[3];
typedef char ip2c_db_ident[5];
typedef unsigned long ip2c_ip;

typedef struct ip2c_db {
	ip2c_db_ident ident;     // IP2C
	unsigned char vers_hi;
	unsigned char vers_lo;
	unsigned long rec_count; // record count
	unsigned long ip_count;  // total count of covered IPs
	ip2c_ip *ip_s;           // ip range start
	ip2c_ip *ip_e;           // ip range end
	ip2c_country_code *ip_c; // ip country code
} ip2c_db;

struct ip2c_db *ip2c_db_init();
int ip2c_db_load(struct ip2c_db *db, const char *file_name);
int ip2c_db_free(struct ip2c_db *db);
int ip2c_getcountry(const struct ip2c_db *db, const unsigned long *ip_array, const unsigned long ip_array_size, ip2c_country_code *iso_codes);
